<%@ page language="java" pageEncoding="UTF-8"%>
<link rel='stylesheet' href='../asset/common/css/bootstrap.min.css'>
<link rel='stylesheet' href='../asset/common/css/page.css'>

<script type='text/javascript' src='../dep/jquery-1.8.2.js'></script>
<script type='text/javascript' src='../dep/esl.js'></script>
<script type='text/javascript' src='../dep/bootstrap.min.js'></script>
<script src='../dep/jquery.base64.js' type='text/javascript'></script>
<style>
.text-right {
	text-align: right;
	width: 8%;
	padding-right: 2px;
}

td {
	padding: 10px;
}

input.radio-margin0 {
	margin: 0;
}

#title {
	margin: 0;
	width: 50%;;
}

#abs {
	height: 60px;
	width: 52%;
}

#detail {
	height: 240px;
	width: 80%;
}

span {
	padding: 0 10px 0 5px;
	vertical-align: middle;
}

.inputsize {
   height: 16px;
   width: 90px;
}
.halfinputsize {
   height: 16px;
   width: 45px;
}
</style>



<div class="control-group">
	<table>
		<tr>
			<td width="20%">
				<font>名称</font>
			</td>
			<td width="80%">
				<input type="text" id="food_name" value="${food.name}" class="inputsize"/>
				<input type="hidden" id="food_foodid" value="${food.foodid}">
				<input type="hidden" id="food_type" value="${food.type}" />
				<input type="hidden" id="food_imagebase" value="${food.image}"/>
				<input type="hidden" id="food_imagebase_pc" value="${food.imagepc}"/>
			</td>
		</tr>
		<tr>
			<td width="20%">
				<font>描述</font>
			</td>
			<td width="80%">
				<textarea id="food_desc" style="height:100%;">${food.desc}</textarea>
			</td>
		</tr>
		<tr>
			<td width="20%">
				<font>图片(APP)</font>
			</td>
			<td width="80%">
				<div><img id="food-image-show" style="width:100px;height:100px" src="${food.image}"/></div>
				<input id="food-image-upload" onchange="showimage(this, 0);" src="#" type="file" accept="image/gif, image/bmp,image/jpeg,image/tiff,image/x-png" alt="foodimage"/>
			</td>
		</tr>
		<tr>
			<td width="20%">
				<font>图片(PC)</font>
			</td>
			<td width="80%">
				<div><img id="food-image-show-pc" style="width:100px;height:100px" src="${food.imagepc}"/></div>
				<input id="food-image-upload-pc" onchange="showimage(this, 1);" src="#" type="file" accept="image/gif, image/bmp,image/jpeg,image/tiff,image/x-png" alt="foodimagepc"/>
			</td>
		</tr>
		<tr>
			<td width="20%">
				<font>标签</font>
			</td>
			<td width="80%">
				<div>
					<table>
						<tr>
							<td>
								<input type="text" id="food_flag1" value="${food.flag1}" class="inputsize"/>
							</td>
							<td>
								<input type="text" id="food_flag2" value="${food.flag2}" class="inputsize"/>
							</td>
							<td>
								<input type="text" id="food_flag3" value="${food.flag3}" class="inputsize"/>
							</td>
						</tr>
						<tr>
							<td>
								<input type="text" id="food_flag4" value="${food.flag4}" class="inputsize"/>
							</td>
							<td>
								<input type="text" id="food_flag5" value="${food.flag5}" class="inputsize"/>
							</td>
						</tr>
					</table>					
				</div>
			</td>
		</tr>
		
		<tr>
			<td width="20%">
				<font>营养值</font>
			</td>
			<td width="80%">
				<div>
					<table>
						<tr>
							<td>
								<font>蛋白质</font>
								<input type="text" id="food_protein" value="${food.protein}" class="inputsize"/>
							</td>
						</tr>
						<tr>
							<td>
								<font>碳水化合物</font>
								<input type="text" id="food_carbo" value="${food.carbo}" class="inputsize"/>
							</td>
						</tr>
						<tr>
							<td>
								<font>脂肪</font>
								<input type="text" id="food_fat" value="${food.fat}" class="inputsize"/>
							</td>
						</tr>
						<tr>
							<td>
								<font>维生素</font>
								<input type="text" id="food_vitamin" value="${food.vitamin}" class="inputsize"/>
							</td>
						</tr>
						<tr>
							<td>
								<font>卡路里</font>
								<input type="text" id="food_calorie" value="${food.calorie}" class="inputsize"/>
							</td>
						</tr>
						<tr>
							<td>
								<font>营养参考值</font>
								<input type="text" id="food_value" value="${food.value}" class="inputsize"/>
							</td>
						</tr>
						<tr>
							<td>
								<font>膳食纤维</font>
								<input type="text" id="food_df" value="${food.df}" class="inputsize"/>
							</td>
						</tr>
						<tr>
							<td>
								<font>矿物质</font>
								<input type="text" id="food_mineral" value="${food.mineral}" class="inputsize"/>
							</td>
						</tr>
					</table>					
				</div>
			</td>
		</tr>
		<tr>
			<td width="20%">
				<font>状态</font>
			</td>
			<td width="80%">
			<input id="hiddenstate" type="hidden" value="${food.state}">
				<select id="food_state" class="input-medium search-query">
					<option value="0">正常使用</option>
					<option value="1">停止使用</option>
				</select>
			</td>
		</tr>
		<tr>
			<td width="20%">
				<font>售价</font>
			</td>
			<td width="80%">
				<input type="text" id="food_price" value="${food.price}" class="inputsize"/>
			</td>
		</tr>
		<tr>
			<td width="20%">
				<font>顺序</font>
			</td>
			<td width="80%">
				<input type="text" id="food_sequence" value="${food.sequence}" class="inputsize"/>
			</td>
		</tr>
	</table>
	<button id="mod_food_confirm" type="button" class="btn btn-primary" data-toggle="button">确定</button>
	<button id="mod_food_cancle" type="button" onclick="cancle();" class="btn btn-primary" data-toggle="button">取消</button>
</div>
<script type="text/javascript">

function cancle()
{
	window.close();
}

require.config({		    
    'baseUrl': '../asset'
});
require(['admin-food-mod'], function(foodmod) {
	foodmod.init();
});
var _html = "";
if($('#hiddenstate').val()==0)
{
	_html += '<option value="0" selected>正常使用</option>';
	_html += '<option value="1">停止使用</option>';
}
else
{
	_html += '<option value="0">正常使用</option>';
	_html += '<option value="1" selected>停止使用</option>';
}
$('#food_state').html(_html);
function showimage(input, type)
{
	if (input.files && input.files[0]) {
		var reader = new FileReader();
		/* if(input.files[0].size>100000)
		{
			alert("图片太大，无法上传，请限制在90k");
		}
		else
		{ */
		if(type == 0){
			reader.onload = function (e) {
	            $('#food-image-show').attr('src', e.target.result);
	            $('#food_imagebase').val(e.target.result);
	        }
	        reader.readAsDataURL(input.files[0]);
		}
		if(type == 1){
			reader.onload = function (e) {
	            $('#food-image-show-pc').attr('src', e.target.result);
	            $('#food_imagebase_pc').val(e.target.result);
	        }
	        reader.readAsDataURL(input.files[0]);
		}
		//}
    }
}


</script>
